package com.monicash.monicash.main.modle

import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.monicash.monicash.base.BaseApplication
import com.monicash.monicash.bean.WeblinkConfigBean
import com.monicash.monicash.netconfig.Apis
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch


class PermisosModle :ViewModel(){

    private val  coroutineScope = CoroutineScope(Dispatchers.Default)
    val weblinkConfigBean: MutableLiveData<WeblinkConfigBean?> = MutableLiveData()

    companion object{
        val instant by lazy (LazyThreadSafetyMode.SYNCHRONIZED){
            PermisosModle()
        }
    }

    fun getWebLinkConfig(){
        coroutineScope.launch {
            try {
                val data = Apis.apiSplashServer.getWebLinkConfig()
                val result = data.bytes()
                Log.e("kgj", "result: $result  result.size: ${result.size}  ")
            }catch (e:Exception){
                Log.e("kgj", "Exception: $e")
            }
        }
    }

    fun getHead():Map<String,Any>{
        val app_id = BaseApplication.getInstance().packageName
        val headMap = HashMap<String,Any>()
        headMap["App_id"] = "com.mc.moring"
        headMap["App_name"] = "MONI CASH"
        headMap["User_Agent"] = "Retrofit-Sample-App"
        headMap["App_version"] = "1.0.0"
        headMap["accept_language"] = "es"
        headMap["Authorization"] = ""
        return headMap
    }

}